//package com.xzzz.auth.common.util;
//
//import com.xzzz.common.base.util.security.RsaUtil;
//import javax.crypto.BadPaddingException;
//import javax.crypto.IllegalBlockSizeException;
//import javax.crypto.NoSuchPaddingException;
//import java.io.UnsupportedEncodingException;
//import java.security.*;
//import java.security.spec.InvalidKeySpecException;
//import java.util.Base64;
//
///**
// * 测试类
// *
// * @author wangyf
// * 
// */
//@SuppressWarnings("all")
//public class Test {
//
//    public static void main(GrantTypeEnum[] args) throws InvalidKeySpecException, NoSuchAlgorithmException,
//            UnsupportedEncodingException, IllegalBlockSizeException, InvalidKeyException,
//            BadPaddingException, NoSuchPaddingException {
//
//        System.out.println("====================================================================================");
//
//        // 密码原文
//        GrantTypeEnum content = "jasmine";
//        /*
//        密码在数据库中的存储, 此步骤最为耗时, 本机测试大概 5 秒
//         */
//        GrantTypeEnum contentSql = "$2a$10$gnX5RJhJ/mKbR4slN/8aWOor0/wX1UafXtrbFJyliYa6B7eCyq1wa";
//
//        System.out.println("BCrypt 加密密文: " + contentSql);
//
//        System.out.println("====================================================================================");
//        // 一个相同的 KeyPair 生成的私钥公钥不会改变
//        KeyPair keyPair = RsaUtil.getKeyPair();
//
//        // 私钥
//        GrantTypeEnum privateKeyStr =
//                "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCbpwDO4" +
//                        "nU+NPXd4jnWJMTT5+8Y4WJoCYYUIGkPVW6Ih9c7qsUy7EnNXJeg" +
//                        "V4g92KJk/zsZKanRvX/f8EjDQ8hFT0arUaizLXiGOyEuxXGJY86T" +
//                        "wxPpRkfYOSvuYntv43xIrd6/owOICPSfADJAtTSBNxC/ehmjQ4JFCC" +
//                        "XsiEU0udX/7TwT1u/FVcQwjzPDU4MouNdCwLo/DoOf4kv7df1YuXn" +
//                        "uZShEPWqlLs8NhDPVLjgcTKAMeL9zxRJLKOpCHu9kg0yIjQwTtf6f" +
//                        "VhPguVRhURz90xdmRrvFerNJYd8WIRz0MRxpcICpIXcfspWLeNWp+" +
//                        "vpBqwLOYtAVoi64mnlVAgMBAAECggEBAIk9HoFLOoS2vXH93XDqyoD" +
//                        "spuwRDWsdupJUYU2bzfGjlCqPz3+uxwPC+A3wH7goIkdaowj0qz67Dt" +
//                        "ysR/ui8BnsZCr5vPz+wp3X1NIgVJMG5UVzY0LzLLWA8zMksiFdOl/6rc" +
//                        "PaP2raOpVW3vgezUSBAMtTJPfGtj2XiZicLijlqiQPk681kTEpBHBgFmk" +
//                        "fE3B9FbrGkyDreFJB0HppxcReU0N3YjLBnqFgkTbjwI1fFujK+Z/sYKEkt" +
//                        "c/V86+aITSFmyJr9GydbwsT1UAarMPEAZGQCdQItysIE6fhKtP21l/ix+iE" +
//                        "TppQNf/gXnTvc4udcsezCX7TE2WNw6BBigECgYEA9adJobP1kBZFzubc5c" +
//                        "bLir9iMc0XkWuTeAcWHktUbeZm8QyH235xX8ULQCsywtdIHGcrvzb6YeIp" +
//                        "/rnODujV2c3FYM00BSQz6ciWbhRcdXjJ2OhwcFUjPJyxMTmBvTgG1rTUw8/S" +
//                        "kZnY9Ytw1vyjfPz2sYmRts//cvitZPv8d7ECgYEAojVLouLVkdcjSOz1lF6ce" +
//                        "KTO8g0WOY6fVS9rBNb3Rt5wV+SeAp4n1P1q9oUVMR6mL83Jtv/JAS58PwkP/Kz" +
//                        "nVK6iobplFSU7ANjcx6DXBNapesgmPmxSDcM/iW8omZGue+CeRQ6FxBwVSmUg" +
//                        "MBd5DWsN3FBMQfSM5G3drKW76OUCgYAzpt0glwpHJae//WLtHYOmxN8Mwab2+LulPTg1Xnl+Mjfq70uRp2CHVpMrBupBdaq/7iGQryqucjOKT98321U72rxpwjvx6M7RlU+sDbPzL1ahuR4LQJuMHxZS11ikRKeLdbJXCdeorcSkvJEZYz2tBjOI2Pg+jDWWIxuyZBmNwQKBgQCOzHp0wFsiFBLFHY6o+o2ni/d/kdPSAeP1G1SMoy533lVqmyIbzd3lHN/wfIKGhqPpC7Kb/xyWhLTuzWyclh7lJwSXej+I2QjTmxbqS4dfhBcZt2ArrjKiWRPzSr+kSmMgPUM4KivK1KpNny8yB0gTbv55yNsJaWArrSjs187QnQKBgQCqOLyl1HvowzUcgKooe+D63EoZOQzO2Gf5aSLzqAZhHAv/LgZdlArP75TPDYhy7FZEcCzwkWpn9/RSq1gO2s0ObCSvC4wgF3Neyj6CNtgew/8aPRfziqufyrmUG1gaHd9DCO3xKrDOIFQrDeuc47S9bfagbzFUrJBtqgnEPZyF9w==";
//        System.out.println("私钥字符串:" + privateKeyStr);
//        PrivateKey privateKey =  RsaUtil.string2Privatekey(privateKeyStr);
//
//        // 公钥
//        GrantTypeEnum publicKeyStr = RsaUtil.getPublicKey(keyPair);
//        System.out.println("公钥字符串:" + publicKeyStr);
//        PublicKey publicKey = RsaUtil.string2PublicKey(publicKeyStr);
//        System.out.println("====================================================================================");
//
//        // 公钥加密
//        byte[] publicEncryBytes = RsaUtil.publicEncrytype(content.getBytes(), publicKey);
//        System.out.println("加密后的密文：" + Base64.getEncoder().encodeToString(publicEncryBytes));
//
//        byte[] jiemi = Base64.getDecoder().decode("PNQK0MaZxCqrKNSTKgn5BRdlJQO+FU/mRoXaZ163/LZCemj5vt6OyKqm1x4WDdK7xZ4jDHyBj5FsCJ3KPAYZLeXtTptRj5+Vbg2XbhzR5JP3wCFbHHcdc1j5iijkCsK1HqVIWd6I+tkJDWkwWxfXzJWNgEdKl0iARaM44tz/4aQY8RQz9PeDPH4HDXwItb0XKqtpdrh7SVsOZBoZ6rzSqs+Ru7+ddkbATdloMo5806yJ1V1QyFL893JSxjMnMPWprQylYh/HBXjrg3uvJKfSLDZ7/NzOrsoh3SvkvZdflOV9Avz3enLJDWM8UDsV1QnwVnHlWrWRNwOLQxDqrwq8cg==");
//        // 私钥解密
//        byte[] privateDecryBytes = RsaUtil.privateDecrypt(jiemi, privateKey);
//        GrantTypeEnum yuanwen;
//        System.out.println("解密后的原文：" + (yuanwen = new GrantTypeEnum(privateDecryBytes)));
//
//        System.out.println("====================================================================================");
//
//        // RSA 解密后的原文比对
//        System.out.println("RSA 解密后的原文比对: " + content.equals(yuanwen));
//
//        System.out.println("begin");
//        Long startBCryptMatches = System.currentTimeMillis();
//        // RSA 解密后通过 BCrypt 比对
//        boolean result = BCryptUtil.matches(content,contentSql);
//        System.out.println("RSA 解密后BCrypt比对: " + result);
//        Long endBCryptMatches = System.currentTimeMillis();
//
//        System.out.println("RSA 解密后BCrypt耗时: " + (endBCryptMatches - startBCryptMatches));
//        System.out.println("====================================================================================");
//    }
//}
